//
//  DBJSettingAndHelpTableViewCell.m
//  DBJ
//
//  Created by 肖浩然的mac on 2016/11/13.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "DBJSettingAndHelpTableViewCell.h"
#import <Masonry.h>

@interface DBJSettingAndHelpTableViewCell ()

//图标
@property(nonatomic,weak)UIImageView  *iconView;

//图标名
@property(nonatomic,weak)UILabel  *nameLabel;

@end

@implementation DBJSettingAndHelpTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //初始化子控件
        [self setupUI];
    }
    
    return self;
    
}
#pragma mark-初始化子控件
-(void)setupUI
{
   //1.创建UIimageView
    UIImageView *imView = [[UIImageView alloc]init];
    //设置UIimageView
    UIImage *im = [UIImage imageNamed:@"content_img_01"];
    
    imView.image = im;
    
    //记录
    self.iconView = imView;
    //.添加contentView
    [self.contentView addSubview:imView];
    
   //宽度
    CGFloat with = 24;
    CGFloat margin = 10;
    //.布局imageView
    [imView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.contentView).offset(margin);
        make.size.mas_equalTo(CGSizeMake(with, 24));
        make.centerY.mas_equalTo(self.contentView);
        
    }];
    //2.创建UIlabel
    UILabel *nameLabel = [[UILabel alloc]init];
    //设置UIlabel
    nameLabel.font = [UIFont systemFontOfSize:15.0];
    nameLabel.text = @"大保⚔来了";
    
    //记录
    self.nameLabel = nameLabel;
    //添加
    [self.contentView addSubview:nameLabel];
    //布局
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(imView.mas_right).offset(margin);
        make.centerY.mas_equalTo(self.contentView);
        
    }];
    
    //3.创建右边尖括号
    UIImageView *imaView = [[UIImageView alloc]init];
    
    //设置右边尖括号
    UIImage *image = [UIImage imageNamed:@"position-right"];
 
    imaView.image = image;
 
    
    //添加
    [self.contentView addSubview:imaView];
    
    [imaView sizeToFit];
    //布局右边尖括号
    [imaView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(self.contentView).offset(-with+10);
        make.centerY.mas_equalTo(self.contentView);
        
    }];
    
 
}

//重写setter进行赋值

-(void)setArrList:(DBJSettingAndHelpTableViewModel *)arrList
{
    _arrList = arrList;
    
    self.iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",arrList.icon]];
    
    self.nameLabel.text = arrList.name;
 
}

@end
